package lookas.screen;

import java.util.Vector;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;

public class MainScreen extends SimpleScreen implements Runnable {
	private Vector addr;
	int i = 0;

	public MainScreen(Screen parent) {
		super(parent);
	}

	protected void init() {
		addr = new Vector();
		form = new Form("Address");
		Command add = new Command("Add address", Command.ITEM, 0);
		addCommand(add, this);
		Command ok = new Command("Geo", Command.ITEM, 1);
		addCommand(ok, new Runnable() {
			public void run() {
				new SaveScreen(MainScreen.this).setAddr(addr);
			}
		});
		run();
	}

	public void run() {
		TextField tf = new TextField("Address " + i++, null, 160,
				TextField.PLAIN);
		addr.addElement(tf);
		form.append(tf);
		Display.getDisplay(parent.getMidlet()).setCurrentItem(tf);
	}

}
